package com.jiaai.web.zfp_back.member;

import com.alibaba.dubbo.config.annotation.Reference;
import com.jiaai.gift.api.ICarApi;
import com.jiaai.member.api.IMemberLevelApi;
import com.jiaai.member.model.MemberLevelConfigVO;
import com.jiaai.util.RestResultGenerator;
import org.springframework.web.bind.annotation.*;
/**
 * class_name:ZMemberLevelConfig
 * describe:TODO
 * create_user:张昉平
 * create_date:2017/12/20
 * create_date:17:24
 */
@RestController
@RequestMapping("/api/v1/admin/mlevelconfig")
public class ZMemberLevelConfig {

    @Reference
    private IMemberLevelApi memberLevelApi;
    @Reference
    private ICarApi iCarApi;

    @GetMapping("/list")
    public Object list(@RequestParam Integer curr){
        return RestResultGenerator.genSuccessResult(memberLevelApi.getAll(curr));
    }

    @PostMapping("/saveoredit")
    public Object saveOrEdit(@RequestBody MemberLevelConfigVO memberLevelConfigVO){
        memberLevelApi.saveOrEdit(memberLevelConfigVO);
        return RestResultGenerator.genSuccessResult("成功");
    }

    @PostMapping("/delete/{id}")
    public Object delete(@PathVariable("id") Integer id){
        memberLevelApi.delete(id);
        return RestResultGenerator.genSuccessResult("成功");
    }

    @GetMapping("/levelGifts/{id}")
    public Object getLevelGifts(@PathVariable Integer id, @RequestParam(required = false, defaultValue = "false") Boolean isEdit){
        return RestResultGenerator.genSuccessResult(memberLevelApi.getLevelGifts(id, isEdit));
    }
}
